 
package ibms_rcp.task.parts;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
import javax.inject.Inject;

import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.TableViewerColumn;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
import org.eclipse.swt.widgets.Text;
import org.eclipse.wb.swt.SWTResourceManager;

public class AssignPart {
	//工作
	private Text taskText;
	//选择工作按钮
	private Button chooseTaskButton;
	
	private TableViewer tableViewer;
	private Table table;
	
	@Inject
	public AssignPart(Composite parent) {
		//TODO Your code here
	}
	
	@PostConstruct
	public void postConstruct(final Composite parent) {
		GridLayout layout = new GridLayout(1, false);
		layout.marginWidth = 10;
		layout.marginHeight = 10;
		parent.setLayout(layout);
		
		Label title = new Label(parent, SWT.NONE);
		title.setFont(SWTResourceManager.getFont("微软雅黑", 9, SWT.BOLD));
		title.setText("工作指派");
		
		Composite taskComposite = new Composite(parent, SWT.NONE);
		taskComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
				1, 1));
		taskComposite.setLayout(new GridLayout(3, false));
		
		//工作编号
		Label taskLabel = new Label(taskComposite, SWT.RIGHT);
		taskLabel.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false,
				false, 1, 1));
		taskLabel.setText("工作编号：");
		taskText = new Text(taskComposite, SWT.BORDER);
		taskText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false,
				1, 1));
		// 选择工作
		chooseTaskButton = new Button(taskComposite, SWT.NONE);
		chooseTaskButton.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER,
				true, false, 1, 1));
		chooseTaskButton.setText("选择工作");
		
		tableViewer = new TableViewer(parent, SWT.BORDER | SWT.FULL_SELECTION);
		table = tableViewer.getTable();
		table.setLinesVisible(true);
		table.setHeaderVisible(true);
		table.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
		
		TableViewerColumn seqViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn seqTableColumn = seqViewerColumn.getColumn();
		seqTableColumn.setResizable(false);
		seqTableColumn.setAlignment(SWT.CENTER);
		seqTableColumn.setWidth(40);
		seqTableColumn.setText("序号");
		
		TableViewerColumn areaViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn areaTableColumn = areaViewerColumn.getColumn();
		areaTableColumn.setAlignment(SWT.CENTER);
		areaTableColumn.setWidth(200);
		areaTableColumn.setText("区域");
		
		TableViewerColumn workerViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn workerTableColumn = workerViewerColumn.getColumn();
		workerTableColumn.setResizable(false);
		workerTableColumn.setAlignment(SWT.CENTER);
		workerTableColumn.setWidth(100);
		workerTableColumn.setText("员工");
		
		TableViewerColumn timeViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn timeTableColumn = timeViewerColumn.getColumn();
		timeTableColumn.setResizable(false);
		timeTableColumn.setAlignment(SWT.CENTER);
		timeTableColumn.setWidth(100);
		timeTableColumn.setText("指派时间");
		
		TableViewerColumn operViewerColumn = new TableViewerColumn(tableViewer, SWT.NONE);
		TableColumn operTableColumn = operViewerColumn.getColumn();
		operTableColumn.setResizable(false);
		operTableColumn.setAlignment(SWT.CENTER);
		operTableColumn.setWidth(100);
		operTableColumn.setText("操作");
		
	}
	
	
	@PreDestroy
	public void preDestroy() {
		//TODO Your code here
	}
	
	
	
}